home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 1.iso / desktop / gv21.zip / GV.FRM < prev    next >
Text File  |  1995-04-03  |  56KB  |  1,950 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Graphics Viewer"
  4.    ClientHeight    =   6795
  5.    ClientLeft      =   105
  6.    ClientTop       =   360
  7.    ClientWidth     =   9525
  8.    ClipControls    =   0   'False
  9.    ForeColor       =   &H00000000&
  10.    Height          =   7200
  11.    Left            =   45
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   453
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   635
  16.    Top             =   15
  17.    Width           =   9645
  18.    Begin Frame Frm_JPEG 
  19.       Caption         =   "JPEG Options"
  20.       Height          =   2055
  21.       Left            =   2640
  22.       TabIndex        =   22
  23.       Top             =   4320
  24.       Visible         =   0   'False
  25.       Width           =   5175
  26.       Begin CheckBox Chk_TPQ 
  27.          Caption         =   "Two-Pass Quantize"
  28.          Height          =   255
  29.          Left            =   2640
  30.          TabIndex        =   32
  31.          Top             =   360
  32.          Width           =   2295
  33.       End
  34.       Begin CheckBox Chk_Do_Fancy 
  35.          Caption         =   "Do Fancy Upsampling"
  36.          Height          =   255
  37.          Left            =   120
  38.          TabIndex        =   31
  39.          Top             =   360
  40.          Width           =   2295
  41.       End
  42.       Begin Frame Frm_DCT 
  43.          Caption         =   "DCT Method"
  44.          Height          =   1215
  45.          Left            =   2640
  46.          TabIndex        =   24
  47.          Top             =   600
  48.          Width           =   2295
  49.          Begin OptionButton Opt_DCT 
  50.             Caption         =   "Floating Point"
  51.             Height          =   255
  52.             Index           =   2
  53.             Left            =   120
  54.             TabIndex        =   30
  55.             Top             =   840
  56.             Width           =   1935
  57.          End
  58.          Begin OptionButton Opt_DCT 
  59.             Caption         =   "Fast Integer"
  60.             Height          =   255
  61.             Index           =   1
  62.             Left            =   120
  63.             TabIndex        =   29
  64.             Top             =   600
  65.             Value           =   -1  'True
  66.             Width           =   1935
  67.          End
  68.          Begin OptionButton Opt_DCT 
  69.             Caption         =   "Slow Integer"
  70.             Height          =   255
  71.             Index           =   0
  72.             Left            =   120
  73.             TabIndex        =   28
  74.             Top             =   360
  75.             Width           =   1935
  76.          End
  77.       End
  78.       Begin Frame Frm_Dither 
  79.          Caption         =   "Dithering Options"
  80.          Height          =   1215
  81.          Left            =   120
  82.          TabIndex        =   23
  83.          Top             =   600
  84.          Width           =   2295
  85.          Begin OptionButton Opt_JPEGDither 
  86.             Caption         =   "Floyd-Steinberg"
  87.             Height          =   255
  88.             Index           =   2
  89.             Left            =   120
  90.             TabIndex        =   27
  91.             Top             =   840
  92.             Width           =   1815
  93.          End
  94.          Begin OptionButton Opt_JPEGDither 
  95.             Caption         =   "Ordered"
  96.             Height          =   255
  97.             Index           =   1
  98.             Left            =   120
  99.             TabIndex        =   26
  100.             Top             =   600
  101.             Value           =   -1  'True
  102.             Width           =   1575
  103.          End
  104.          Begin OptionButton Opt_JPEGDither 
  105.             Caption         =   "None"
  106.             Height          =   255
  107.             Index           =   0
  108.             Left            =   120
  109.             TabIndex        =   25
  110.             Top             =   360
  111.             Width           =   1575
  112.          End
  113.       End
  114.    End
  115.    Begin Frame Frame1 
  116.       Height          =   6615
  117.       Left            =   120
  118.       TabIndex        =   7
  119.       Top             =   0
  120.       Width           =   2175
  121.       Begin OptionButton Opt_Dither 
  122.          Caption         =   "No Dithering"
  123.          Height          =   255
  124.          Index           =   0
  125.          Left            =   120
  126.          TabIndex        =   21
  127.          Top             =   3960
  128.          Value           =   -1  'True
  129.          Width           =   1935
  130.       End
  131.       Begin OptionButton Opt_Dither 
  132.          Caption         =   "Dither extra colors"
  133.          Height          =   255
  134.          Index           =   2
  135.          Left            =   120
  136.          TabIndex        =   20
  137.          Top             =   4440
  138.          Width           =   1935
  139.       End
  140.       Begin OptionButton Opt_Dither 
  141.          Caption         =   "Dither always"
  142.          Height          =   255
  143.          Index           =   1
  144.          Left            =   120
  145.          TabIndex        =   19
  146.          Top             =   4200
  147.          Width           =   1935
  148.       End
  149.       Begin Frame Frame2 
  150.          Caption         =   "Scale"
  151.          Height          =   855
  152.          Left            =   120
  153.          TabIndex        =   14
  154.          Top             =   4680
  155.          Width           =   1935
  156.          Begin OptionButton Opt_Scale 
  157.             Caption         =   "400%"
  158.             Height          =   255
  159.             Index           =   3
  160.             Left            =   1080
  161.             TabIndex        =   18
  162.             Top             =   480
  163.             Width           =   735
  164.          End
  165.          Begin OptionButton Opt_Scale 
  166.             Caption         =   "300%"
  167.             Height          =   255
  168.             Index           =   2
  169.             Left            =   1080
  170.             TabIndex        =   17
  171.             Top             =   240
  172.             Width           =   735
  173.          End
  174.          Begin OptionButton Opt_Scale 
  175.             Caption         =   "200%"
  176.             Height          =   255
  177.             Index           =   1
  178.             Left            =   120
  179.             TabIndex        =   16
  180.             Top             =   480
  181.             Width           =   735
  182.          End
  183.          Begin OptionButton Opt_Scale 
  184.             Caption         =   "100%"
  185.             Height          =   255
  186.             Index           =   0
  187.             Left            =   120
  188.             TabIndex        =   15
  189.             Top             =   240
  190.             Value           =   -1  'True
  191.             Width           =   735
  192.          End
  193.       End
  194.       Begin CommandButton Cmd_Disp 
  195.          Caption         =   "Print"
  196.          Height          =   375
  197.          Index           =   1
  198.          Left            =   1200
  199.          TabIndex        =   13
  200.          Top             =   5640
  201.          Width           =   855
  202.       End
  203.       Begin CommandButton Cmd_Info 
  204.          Caption         =   "Info"
  205.          Height          =   375
  206.          Left            =   120
  207.          TabIndex        =   12
  208.          Top             =   5640
  209.          Width           =   855
  210.       End
  211.       Begin FileListBox File1 
  212.          Height          =   2175
  213.          Left            =   120
  214.          Pattern         =   "*.bmp;*.tif;*.gif;*.wpg;*.pcx;*.pic;*.tga;*.msp;*.iff;*.lbm;*.mac;*.gem;*.img;*.cut;*.dib;*.rle;*.wmf;*.jpg;*.ras;*.art;*.hrz"
  215.          TabIndex        =   11
  216.          Top             =   1680
  217.          Width           =   1935
  218.       End
  219.       Begin DirListBox Dir1 
  220.          Height          =   930
  221.          Left            =   120
  222.          TabIndex        =   10
  223.          Top             =   480
  224.          Width           =   1935
  225.       End
  226.       Begin CommandButton Cmd_Disp 
  227.          Caption         =   "Display"
  228.          Height          =   375
  229.          Index           =   0
  230.          Left            =   120
  231.          TabIndex        =   9
  232.          Top             =   6120
  233.          Width           =   855
  234.       End
  235.       Begin CommandButton Cmd_Exit 
  236.          Caption         =   "Exit"
  237.          Height          =   375
  238.          Left            =   1200
  239.          TabIndex        =   8
  240.          Top             =   6120
  241.          Width           =   855
  242.       End
  243.       Begin Label Label1 
  244.          Caption         =   "&Directories"
  245.          Height          =   255
  246.          Index           =   0
  247.          Left            =   120
  248.          TabIndex        =   0
  249.          Top             =   240
  250.          Width           =   1095
  251.       End
  252.       Begin Label Label1 
  253.          Caption         =   "&Files"
  254.          Height          =   255
  255.          Index           =   1
  256.          Left            =   120
  257.          TabIndex        =   1
  258.          Top             =   1440
  259.          Width           =   1095
  260.       End
  261.    End
  262.    Begin PictureBox Picture2 
  263.       BackColor       =   &H00C0C0C0&
  264.       Height          =   255
  265.       Left            =   9240
  266.       ScaleHeight     =   225
  267.       ScaleWidth      =   225
  268.       TabIndex        =   6
  269.       Top             =   6600
  270.       Visible         =   0   'False
  271.       Width           =   255
  272.    End
  273.    Begin VScrollBar VScroll1 
  274.       Height          =   6615
  275.       LargeChange     =   100
  276.       Left            =   9240
  277.       SmallChange     =   20
  278.       TabIndex        =   5
  279.       Top             =   0
  280.       Visible         =   0   'False
  281.       Width           =   255
  282.    End
  283.    Begin HScrollBar HScroll1 
  284.       Height          =   255
  285.       LargeChange     =   100
  286.       Left            =   0
  287.       SmallChange     =   20
  288.       TabIndex        =   4
  289.       Top             =   6600
  290.       Visible         =   0   'False
  291.       Width           =   9255
  292.    End
  293.    Begin PictureBox Pic_Graphic 
  294.       Height          =   3135
  295.       Left            =   0
  296.       ScaleHeight     =   207
  297.       ScaleMode       =   3  'Pixel
  298.       ScaleWidth      =   287
  299.       TabIndex        =   3
  300.       Top             =   0
  301.       Visible         =   0   'False
  302.       Width           =   4335
  303.    End
  304.    Begin ListBox Lst_Info 
  305.       Height          =   6465
  306.       Left            =   2400
  307.       TabIndex        =   2
  308.       Top             =   120
  309.       Visible         =   0   'False
  310.       Width           =   6975
  311.    End
  312.    Begin Menu Mnu_Close 
  313.       Caption         =   "&Close"
  314.       Visible         =   0   'False
  315.    End
  316. End
  317. Option Explicit
  318. DefInt A-Z
  319. Dim Fi%, File$
  320. Dim Ret%
  321. Dim IntMot%
  322. Dim Tags$(254 To 532)
  323. Dim Typs$(4)
  324. Dim Errors$(-13 To -1)
  325. Dim PX%, PY%
  326. Dim dhDC%, dhWnd%
  327. Dim Dither%, Prn%, Scle%
  328. Dim BT As String * 1
  329. Dim Canc%, Found_BMP%, BMPhndl%
  330.  
  331. Sub Cmd_Disp_Click (Index As Integer)
  332.     On Error GoTo Er_hndl:
  333.  
  334.     Dim A$, HL&, I%, Ret%, DM%, DCTM%
  335.     Dim Wdth%, Hght%, Lft%, Tp%
  336.     Dim hMF%, Buffer&, gptr&
  337.     Dim TempDC%, hDCprev%, SavDC%
  338.     Dim WMFH As METAFILEHEADER
  339.  
  340.     If File1.ListIndex < 0 Then Beep: Exit Sub
  341.     Frm_JPEG.Visible = False
  342.     Screen.MousePointer = 11
  343.     File$ = Dir1.Path & "\" & File1.List(File1.ListIndex)
  344.     A$ = Right$(File$, 3)
  345.     Found_BMP = False
  346.     If Index = 0 Then
  347.     Frame1.Visible = False
  348.     Lst_Info.Visible = False
  349.     Ret = DoEvents()
  350.     Pic_Graphic.Cls
  351.     
  352.     Pic_Graphic.AutoRedraw = False
  353.     dhDC = Pic_Graphic.hDC
  354.     dhWnd = Pic_Graphic.hWnd
  355.     Prn = False
  356.     Else
  357.     Printer.Print " "
  358.     dhDC = Printer.hDC
  359.     dhWnd = 0
  360.     Prn = True
  361.     End If
  362.     For I = 0 To 3
  363.     If Opt_Scale(I).Value Then Scle = I + 1
  364.     Next I
  365.     For I = 0 To 2
  366.     If Opt_Dither(I).Value Then Dither = I
  367.     Next I
  368.  
  369.     Select Case A$
  370.     Case "art"
  371.     BMPhndl = ReadART(File$, dhDC, dhWnd, Prn, 0, 0, Scle)
  372.     
  373.     Case "bmp"
  374.     BMPhndl = ReadBMP(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  375.     
  376.     Case "cut"
  377.     BMPhndl = ReadCUT(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  378.     
  379.     Case "dib"
  380.     BMPhndl = ReadBMP(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  381.     
  382.     Case "gem"
  383.     BMPhndl = ReadIMG(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  384.     
  385.     Case "gif"
  386.     Disp_GIF
  387.     If BMPhndl > 0 And Prn = False Then Exit Sub
  388.     
  389.     Case "hrz"
  390.     BMPhndl = ReadHRZ(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  391.  
  392.     Case "iff"
  393.     BMPhndl = ReadIFF(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  394.     
  395.     Case "img"
  396.     BMPhndl = ReadIMG(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  397.     
  398.     Case "jpg"
  399.     For I = 0 To 2
  400.         If Opt_JPEGDither(I).Value Then DM = I
  401.         If Opt_DCT(I).Value Then DCTM = I
  402.     Next I
  403.     BMPhndl = ReadJPG(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle, Chk_Do_Fancy.Value, Chk_TPQ.Value, DM, DCTM)
  404.     
  405.     Case "lbm"
  406.     BMPhndl = ReadIFF(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  407.     
  408.     Case "mac"
  409.     BMPhndl = ReadMAC(File$, dhDC, dhWnd, Prn, 0, 0, Scle)
  410.     
  411.     Case "msp"
  412.     BMPhndl = ReadMSP(File$, dhDC, dhWnd, Prn, 0, 0, Scle)
  413.     
  414.     Case "pcx"
  415.     BMPhndl = ReadPCX(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  416.     
  417.     Case "pic"
  418.     BMPhndl = ReadPIC(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  419.  
  420.     Case "ras"
  421.     BMPhndl = ReadRAS(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  422.  
  423.     Case "rle"
  424.     BMPhndl = ReadBMP(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  425.     
  426.     Case "tga"
  427.     BMPhndl = ReadTGA(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  428.  
  429.     Case "tif"
  430.     BMPhndl = ReadTIF(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  431.      
  432.     Case "wmf"
  433.     If Index = 0 Then
  434.         Pic_Graphic.AutoSize = True
  435.         Pic_Graphic.Picture = LoadPicture(File$)
  436.         BMPhndl = 0
  437.         Pic_Graphic.AutoSize = False
  438.     Else
  439.         Printer.ScaleMode = 3
  440.         SavDC = SaveDC(Printer.hDC)
  441.         Fi = FreeFile
  442.         Open File$ For Binary As #Fi
  443.         Get #Fi, , WMFH
  444.         If WMFH.key = &H9AC6CDD7 Then
  445.         Wdth = ((WMFH.bbox.right - WMFH.bbox.Left) / WMFH.inch) * (1440 / Printer.TwipsPerPixelX)
  446.         Hght = ((WMFH.bbox.Bottom - WMFH.bbox.Top) / WMFH.inch) * (1440 / Printer.TwipsPerPixelY)
  447.         Buffer = LOF(Fi) - 22
  448.         hMF = GlobalAlloc(GMEM_MOVEABLE, Buffer)
  449.         If hMF <> 0 Then
  450.             gptr = GlobalLock(hMF)
  451.             Ret = lread(Fi, gptr, Buffer)
  452.             Close Fi
  453.         End If
  454.         Else
  455.         Close Fi
  456.         Wdth = 600                  ' Arbitrary setting
  457.         Hght = 600                  ' Arbitrary setting
  458.         hMF = GetMetaFile(File$)
  459.         End If
  460.         Ret = SetMapMode(Printer.hDC, MM_ANISOTROPIC)
  461.         Lft = (Printer.ScaleWidth - Wdth) / 2
  462.         Tp = (Printer.ScaleHeight - Hght) / 2
  463.         HL = SetViewportOrg(Printer.hDC, Lft, Tp)
  464.         HL = SetViewportExt(Printer.hDC, Wdth, Hght)
  465.         Ret = PlayMetaFile(Printer.hDC, hMF)
  466.         If WMFH.key = &H9AC6CDD7 Then
  467.         Ret = GlobalUnlock(hMF)
  468.         Ret = GlobalFree(hMF)
  469.         Else
  470.         Ret = DeleteMetaFile(hMF)
  471.         End If
  472.         Ret = RestoreDC(Printer.hDC, SavDC)
  473.     End If
  474.  
  475.     Case "wpg"
  476.     BMPhndl = ReadWPG(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle)
  477.  
  478.     Case Else
  479.     Frame1.Visible = True
  480.     Screen.MousePointer = 0
  481.     Exit Sub
  482.  
  483.     End Select
  484.  
  485.     If BMPhndl >= 0 And Prn = False Then
  486.     Mnu_Close.Visible = True
  487.     Pic_Graphic.Width = Pic_Graphic.Width * Scle
  488.     Pic_Graphic.Height = Pic_Graphic.Height * Scle
  489.     Form_Resize
  490.     If BMPhndl > 0 Then Pic_Graphic.Picture = ClipBoard.GetData(9)
  491.     Ret = DoEvents()
  492.     Pic_Graphic.AutoRedraw = True
  493.     If BMPhndl > 0 Then
  494.         TempDC = CreateCompatibleDC(Pic_Graphic.hDC)
  495.         hDCprev = SelectObject(TempDC, BMPhndl)
  496.         Ret = StretchBlt(Pic_Graphic.hDC, 0, 0, Pic_Graphic.Width, Pic_Graphic.Height, TempDC, 0, 0, Pic_Graphic.Width / Scle, Pic_Graphic.Height / Scle, SRCCOPY)
  497.         Ret = SelectObject(TempDC, hDCprev)
  498.         Ret = DeleteDC(TempDC)
  499.         Ret = DeleteObject(BMPhndl)
  500.         Pic_Graphic.Visible = True
  501.     End If
  502.     End If
  503.     If BMPhndl < 0 Then
  504.     Screen.MousePointer = 0
  505.     Beep
  506.     If BMPhndl < -13 Then BMPhndl = -13
  507.     MsgBox "Error occurred - " & Errors$(BMPhndl), 48, "Graphics Viewer"
  508.     Frame1.Visible = True
  509.     End If
  510.     If Index = 1 Then Printer.EndDoc
  511.     Screen.MousePointer = 0
  512.     Exit Sub
  513.  
  514. Er_hndl:
  515.     Beep
  516.     Screen.MousePointer = 0
  517.     If TempDC Then Ret = DeleteDC(TempDC)
  518.     If BMPhndl Then Ret = DeleteObject(BMPhndl)
  519.     MsgBox Error$, 48, "Graphics Viewer"
  520.     Exit Sub
  521. End Sub
  522.  
  523. Sub Cmd_Exit_Click ()
  524.     Unload Form1
  525. End Sub
  526.  
  527. Sub Cmd_Info_Click ()
  528.     If File1.ListIndex < 0 Then Beep: Exit Sub
  529.     Screen.MousePointer = 11
  530.     Hscroll1.Visible = False
  531.     Vscroll1.Visible = False
  532.     Picture2.Visible = False
  533.     Found_BMP = False
  534.     Lst_Info.Clear
  535.     Lst_Info.Visible = True
  536.     Pic_Graphic.Visible = False
  537.     File$ = Dir1.Path & "\" & File1.List(File1.ListIndex)
  538.     Frm_JPEG.Visible = False
  539.  
  540.     Select Case Right$(File$, 3)
  541.     Case "art"
  542.     Info_ART
  543.  
  544.     Case "bmp"
  545.     Info_BMP
  546.  
  547.     Case "cut"
  548.     Info_CUT
  549.  
  550.     Case "dib"
  551.     Info_BMP
  552.     
  553.     Case "gem"
  554.     Info_IMG
  555.     
  556.     Case "gif"
  557.     Info_GIF
  558.  
  559.     Case "hrz"
  560.     Info_HRZ
  561.  
  562.     Case "iff"
  563.     Info_IFF
  564.     
  565.     Case "img"
  566.     Info_IMG
  567.     
  568.     Case "jpg"
  569.     Info_JPG
  570.     Frm_JPEG.Visible = True
  571.  
  572.     Case "lbm"
  573.     Info_IFF
  574.  
  575.     Case "mac"
  576.     Info_MAC
  577.  
  578.     Case "msp"
  579.     Info_MSP
  580.  
  581.     Case "pcx"
  582.     Info_PCX
  583.  
  584.     Case "pic"
  585.     Info_PIC
  586.     
  587.     Case "ras"
  588.     Info_RAS
  589.  
  590.     Case "rle"
  591.     Info_BMP
  592.  
  593.     Case "tga"
  594.     Info_TGA
  595.     
  596.     Case "tif"
  597.     Info_TIF
  598.  
  599.     Case "wmf"
  600.     Info_WMF
  601.  
  602.     Case "wpg"
  603.     Info_WPG
  604.     
  605.     End Select
  606.     Close
  607.     Screen.MousePointer = 0
  608. End Sub
  609.  
  610. Function CnvtInt& (in$)
  611.     Dim C&
  612.     C = Asc(Left$(in$, 1))
  613.     CnvtInt = C * 256 + Asc(Right$(in$, 1))
  614. End Function
  615.  
  616. Function CnvtLng# (Lng$)
  617.     Dim C#, I#
  618.     For I = 3 To 0 Step -1
  619.     C = C + Asc(Mid$(Lng$, 4 - I, 1)) * 256 ^ I
  620.     Next I
  621.     CnvtLng = C
  622. End Function
  623.  
  624. Sub Dir1_Change ()
  625.     File1.Path = Dir1.Path
  626. End Sub
  627.  
  628. Sub Disp_GIF ()
  629.     Dim GIF As GIFHEADER
  630.     Dim Image As IMAGEBLOCK
  631.     Dim TempDC%, hDCprev%
  632.     Dim Oldfont%, Newfont%
  633.     Dim CX%, CY%, X%, Y%
  634.     Dim A$, I%
  635.     Dim Flag%
  636.     Dim NumClrs%, NumClrBits%
  637.     Dim Offset&, ImgOffset&
  638.     Dim Clr%
  639.     Dim Pal$
  640.  
  641.     Fi = FreeFile
  642.     Open File$ For Binary As Fi
  643.     Get #Fi, , GIF
  644.     Flag = Asc(GIF.Flags)
  645.     If (Flag And &H80) Then
  646.     NumClrBits = (Flag And &H7) + 1
  647.     NumClrs = 2 ^ NumClrBits
  648.     Pal$ = String$(NumClrs * 3, 0)
  649.     Get #Fi, , Pal$
  650.     End If
  651.     Do
  652.     Get #Fi, , BT$
  653.     Select Case BT$
  654.     Case ","
  655.         ImgOffset = Seek(Fi) - 1
  656.         If Found_BMP Then
  657.         Beep
  658.         Ret = MsgBox("There is another graphic in this file, Display it?", 36, "GIF Reader")
  659.         If Ret = 7 Then Close : Exit Sub
  660.         Pic_Graphic.AutoRedraw = False
  661.         Pic_Graphic.Cls
  662.         End If
  663.         Get #Fi, , Image
  664.         Flag = Asc(Image.Flags)
  665.         If (Flag And &H80) Then
  666.         NumClrBits = (Flag And &H7) + 1
  667.         NumClrs = 2 ^ NumClrBits
  668.         Pal$ = String$(NumClrs * 3, 0)
  669.         Get #Fi, , Pal$
  670.         End If
  671.         Offset = Seek(Fi)
  672.         Close
  673.         BMPhndl = ReadGIF(File$, dhDC, dhWnd, Dither, Prn, 0, 0, Scle, ImgOffset)
  674.         If Prn Then Exit Sub
  675.         Fi = FreeFile
  676.         Open File$ For Binary As Fi
  677.         Seek #Fi, Offset
  678.         Screen.MousePointer = 0
  679.         If BMPhndl > 0 And Prn = 0 Then
  680.         Found_BMP = True
  681.         Mnu_Close.Visible = True
  682.         Pic_Graphic.Width = Pic_Graphic.Width * Scle
  683.         Pic_Graphic.Height = Pic_Graphic.Height * Scle
  684.         Form_Resize
  685.         If BMPhndl > 0 Then Pic_Graphic.Picture = ClipBoard.GetData(9)
  686.         Ret = DoEvents()
  687.         Pic_Graphic.AutoRedraw = True
  688.         TempDC = CreateCompatibleDC(Pic_Graphic.hDC)
  689.         hDCprev = SelectObject(TempDC, BMPhndl)
  690.         Ret = StretchBlt(Pic_Graphic.hDC, 0, 0, Pic_Graphic.Width, Pic_Graphic.Height, TempDC, 0, 0, Pic_Graphic.Width / Scle, Pic_Graphic.Height / Scle, SRCCOPY)
  691.         Ret = SelectObject(TempDC, hDCprev)
  692.         Ret = DeleteDC(TempDC)
  693.         Ret = DeleteObject(BMPhndl)
  694.         Pic_Graphic.Visible = True
  695.         End If
  696.         I = GetC()
  697.         I = 1
  698.         Do Until I = 0
  699.         I = GetC()
  700.         Seek #Fi, Seek(Fi) + I
  701.         Loop
  702.         
  703.     Case "!"
  704.         Get #Fi, , BT$
  705.  
  706.         Select Case Asc(BT$)          ' Plain Text Extension
  707.         Case 1
  708.         Dim PlnTxt As PLAINTEXT
  709.         Dim lf As LOGFONT
  710.         Dim tm As TEXTMETRIC
  711.         Ret = GetTextMetrics(Pic_Graphic.hDC, tm)
  712.         lf.lfweight = tm.tmweight
  713.         Get #Fi, , PlnTxt
  714.         Clr = Asc(PlnTxt.ForeColor)
  715.         Pic_Graphic.ForeColor = RGB(Asc(Mid$(Pal$, Clr * 3 + 1, 1)), Asc(Mid$(Pal$, Clr * 3 + 2, 1)), Asc(Mid$(Pal$, Clr * 3 + 3, 1)))
  716.         Clr = Asc(PlnTxt.BackColor)
  717.         Pic_Graphic.BackColor = RGB(Asc(Mid$(Pal$, Clr * 3 + 1, 1)), Asc(Mid$(Pal$, Clr * 3 + 2, 1)), Asc(Mid$(Pal$, Clr * 3 + 3, 1)))
  718.         X = PlnTxt.GridWidth
  719.         Y = PlnTxt.GridHeight
  720.         Pic_Graphic.CurrentY = PlnTxt.Top
  721.         lf.lfheight = Asc(PlnTxt.CellWidth)
  722.         lf.lfwidth = Asc(PlnTxt.CellHeight)
  723.         Newfont% = CreateFontIndirect%(lf)
  724.         Oldfont% = SelectObject%(Pic_Graphic.hDC, Newfont%)
  725.         CX = 0: CY = 0
  726.         Do
  727.         For I = 1 To GetC()
  728.         Get #Fi, , BT$
  729.         If BT$ = Chr$(0) Or EOF(Fi) Then Exit Do
  730.         If BT$ = Chr$(13) Then
  731.             CY = CY + Y: CX = 0
  732.         Else
  733.             Ret = TextOut%(Pic_Graphic.hDC, PlnTxt.Left + CX, PlnTxt.Top + CY, BT$, 1)
  734.         End If
  735.         CX = CX + X
  736.         Next I
  737.         Loop
  738.         Newfont% = SelectObject%(Pic_Graphic.hDC, Oldfont%)
  739.         Ret = DeleteObject%(Newfont%)
  740.         
  741.         Case 249                          'Control Block Extension
  742.         Dim Cntrlblk As CONTROLBLOCK
  743.         Get #Fi, , Cntrlblk
  744.         Flag = Asc(Cntrlblk.Flags)
  745.         Select Case (Flag * 4) And &H7
  746.         Case 0
  747.             A$ = "No disposal specified"
  748.  
  749.         Case 1
  750.             A$ = "Do not dispose"
  751.  
  752.         Case 2
  753.             A$ = "Dispose to background color"
  754.  
  755.         Case 3
  756.             A$ = "Dispose to previous graphic"
  757.  
  758.         Case Else
  759.             A$ = "Unknown disposal procedure"
  760.         
  761.         End Select
  762.  
  763.         Beep
  764.         MsgBox A$, 0, "Control Block"
  765.         
  766.         If Flag And &H2 Then
  767.             MsgBox "User input required, delay for " & Format$(Cntrlblk.Delay) & " seconds", 0, "Control Block"
  768.         End If
  769.  
  770.         If Flag And &H1 Then
  771.             MsgBox "Transparent color: " & Format$(Asc(Cntrlblk.Transparent_Color)), 0, "Control Block"
  772.         Else
  773.             MsgBox "No transparent color", 0, "GIF Reader"
  774.         End If
  775.         
  776.         Case 254                   'Comment Extension
  777.         A$ = ""
  778.         Do
  779.         For I = 1 To GetC()
  780.         Get #Fi, , BT$
  781.         If BT$ = Chr$(0) Or EOF(Fi) Then Exit Do
  782.         A$ = A$ & BT$
  783.         Next I
  784.         Loop
  785.         Beep
  786.         MsgBox A$, 64, "GIF Reader"
  787.          
  788.         Case 255                             'Application Extension
  789.         Dim Appl As Application
  790.         Get #Fi, , Appl
  791.         MsgBox "Application identification string: " & Appl.Applstring, 0, "Application Block"
  792.         Do
  793.         For I = 1 To GetC()
  794.         Get #Fi, , BT$
  795.         If BT$ = Chr$(0) Or EOF(Fi) Then Exit Do
  796.         Next I
  797.         Loop
  798.  
  799.         Case Else
  800.         MsgBox "Skipping unknown control block" & Format$(Asc(BT$)), 0, "GIF Reader"
  801.         Do
  802.         For I = 1 To GetC()
  803.         Get #Fi, , BT$
  804.         If BT$ = Chr$(0) Or EOF(Fi) Then Exit Do
  805.         Next I
  806.         Loop
  807.         
  808.         End Select
  809.  
  810.     Case Chr$(0)
  811.         If EOF(Fi) Then Exit Do
  812.     
  813.     Case Else
  814.         Exit Do
  815.  
  816.     End Select
  817.     Loop
  818.     Close
  819. End Sub
  820.  
  821. Sub File1_Click ()
  822.     Cmd_Info_Click
  823. End Sub
  824.  
  825. Sub File1_DblClick ()
  826.     Cmd_Disp_Click 0
  827. End Sub
  828.  
  829. Function First_Marker ()
  830.     Dim C1, C2
  831.     C1 = GetC()
  832.     C2 = GetC()
  833.     If C1 <> &HFF Or C2 <> M_SOI Then
  834.     MsgBox "Not a JPEG file", 48, "Graphics Viewer"
  835.     Close Fi
  836.     First_Marker = -1
  837.     Exit Function
  838.     End If
  839.     First_Marker = C2
  840. End Function
  841.  
  842. Sub Form_Load ()
  843.     Dim I
  844.     
  845.     Ret = SendMessage(Lst_Info.hWnd, LB_SETTABSTOPS, 1, 70)
  846.     For I = 254 To 532
  847.     Tags(I) = "Unknown"
  848.     Next I
  849.     Typs(0) = "Byte"
  850.     Typs(1) = "ASCII"
  851.     Typs(2) = "Unsigned Int"
  852.     Typs(3) = "Unsigned Long"
  853.     Typs(4) = "Rational"
  854.     Tags(254) = "NewSubFileType"
  855.     Tags(255) = "SubFileType"
  856.     Tags(256) = "ImageWidth"
  857.     Tags(257) = "ImageHeight"
  858.     Tags(258) = "BitsPerSample"
  859.     Tags(259) = "Compression"
  860.     Tags(262) = "PhotometricInterpretation"
  861.     Tags(263) = "Threshholding"
  862.     Tags(264) = "CellWidth"
  863.     Tags(265) = "CellLength"
  864.     Tags(266) = "FillOrder"
  865.     Tags(269) = "DocumentName"
  866.     Tags(270) = "ImageDescription"
  867.     Tags(271) = "Make"
  868.     Tags(272) = "Model"
  869.     Tags(273) = "StripOffsets"
  870.     Tags(274) = "Orientation"
  871.     Tags(277) = "SamplesPerPixel"
  872.     Tags(278) = "RowsPerStrip"
  873.     Tags(279) = "StripByteCounts"
  874.     Tags(280) = "MinSampleValue"
  875.     Tags(281) = "MaxSampleValue"
  876.     Tags(282) = "XResolution"
  877.     Tags(283) = "YResolution"
  878.     Tags(284) = "PlanarConfiguration"
  879.     Tags(285) = "PageName"
  880.     Tags(286) = "XPosition"
  881.     Tags(287) = "YPosition"
  882.     Tags(288) = "FreeOffsets"
  883.     Tags(289) = "FreeByteCounts"
  884.     Tags(290) = "GrayResponseUnit"
  885.     Tags(291) = "GrayResponseCurve"
  886.     Tags(292) = "Group3Options"
  887.     Tags(293) = "Group4Options"
  888.     Tags(296) = "ResolutionUnit"
  889.     Tags(297) = "PageNumber"
  890.     Tags(300) = "ColorResponseUnit"
  891.     Tags(301) = "ColorResponseCurves"
  892.     Tags(305) = "Software"
  893.     Tags(306) = "DateTime"
  894.     Tags(315) = "Artist"
  895.     Tags(316) = "HostComputer"
  896.     Tags(317) = "Predictor"
  897.     Tags(318) = "WhitePoint"
  898.     Tags(319) = "PrimaryChromaticities"
  899.     Tags(320) = "ColorMap"
  900.     Tags(321) = "HalfToneHints"
  901.     Tags(322) = "TileWidth"
  902.     Tags(323) = "TileLength"
  903.     Tags(324) = "TileOffsets"
  904.     Tags(325) = "TileByteCounts"
  905.     Tags(326) = "BadFaxLines"
  906.     Tags(327) = "CleanFaxData"
  907.     Tags(328) = "ConsecutiveBadFaxLines"
  908.     Tags(332) = "InkSet"
  909.     Tags(333) = "InkNames"
  910.     Tags(334) = "NumberofInks"
  911.     Tags(336) = "DotRange"
  912.     Tags(337) = "TargetPrinter"
  913.     Tags(338) = "ExtraSamples"
  914.     Tags(339) = "SampleFormat"
  915.     Tags(340) = "SMinSampleValue"
  916.     Tags(341) = "SMaxSampleValue"
  917.     Tags(342) = "TransferRange"
  918.     Tags(512) = "JPEGProc"
  919.     Tags(513) = "JPEGInterchangeFormat"
  920.     Tags(514) = "JPEGInterchangeFormatLength"
  921.     Tags(515) = "JPEGRestartInterval"
  922.     Tags(517) = "JPEGLosslessPredictors"
  923.     Tags(518) = "JPEGPointTransforms"
  924.     Tags(519) = "JPEGQTables"
  925.     Tags(520) = "JPEGDCTTables"
  926.     Tags(521) = "JPEGACCTTables"
  927.     Tags(529) = "YCbCrCoefficients"
  928.     Tags(530) = "YCbCrSubSampling"
  929.     Tags(531) = "YCbCrPositioning"
  930.     Tags(532) = "ReferenceBlackWhite"
  931.     Errors$(-1) = "Could not open file"
  932.     Errors$(-2) = "Error allocating memory"
  933.     Errors$(-3) = "Error reading file"
  934.     Errors$(-4) = "Error creating DIB"
  935.     Errors$(-5) = "Could not create bitmap"
  936.     Errors$(-6) = "Could not allocate memory for DIB"
  937.     Errors$(-7) = "Bad code in GIF file"
  938.     Errors$(-8) = "Bad first code in GIF file"
  939.     Errors$(-9) = "Bad bit count in GIF file"
  940.     Errors$(-10) = "Bad header in file"
  941.     Errors$(-11) = "No bitmap found in file"
  942.     Errors$(-12) = "Could not create or realize palette"
  943.     Errors$(-13) = "Unknown Error"
  944.     Ret = GetDeviceCaps(Pic_Graphic.hDC, PLANES) * GetDeviceCaps(Pic_Graphic.hDC, BITSPIXEL)
  945.     If Ret <= 8 Then Opt_Dither(2).Value = True
  946.     Move 0, 0
  947.     Width = Screen.Width
  948.     Height = Screen.Height
  949. End Sub
  950.  
  951. Sub Form_Resize ()
  952.     If Pic_Graphic.Height > Form1.ScaleHeight Then
  953.     Vscroll1.Visible = True
  954.     Else
  955.     Vscroll1.Visible = False
  956.     End If
  957.     If Pic_Graphic.Width > Form1.ScaleWidth Then
  958.     Hscroll1.Visible = True
  959.     Else
  960.     Hscroll1.Visible = False
  961.     End If
  962.     Vscroll1.Max = Pic_Graphic.Height - Form1.ScaleHeight + Hscroll1.Height
  963.     Hscroll1.Max = Pic_Graphic.Width - Form1.ScaleWidth + Vscroll1.Width
  964.     If Vscroll1.Visible Or Hscroll1.Visible Then
  965.     Picture2.Visible = True
  966.     Else
  967.     Picture2.Visible = False
  968.     End If
  969.     Hscroll1.Width = Form1.ScaleWidth - Vscroll1.Width
  970.     Vscroll1.Height = Form1.ScaleHeight - Hscroll1.Height
  971.     Hscroll1.Move 0, Form1.ScaleHeight - Hscroll1.Height
  972.     Vscroll1.Move Form1.ScaleWidth - Vscroll1.Width, 0
  973.     Picture2.Move Form1.ScaleWidth - Vscroll1.Width, Form1.ScaleHeight - Hscroll1.Height
  974.     Vscroll1.Max = Pic_Graphic.Height - Form1.ScaleHeight + Hscroll1.Height
  975.     Hscroll1.Max = Pic_Graphic.Width - Form1.ScaleWidth + Vscroll1.Width
  976. End Sub
  977.  
  978. Function GetC% ()
  979.     Get #Fi, , BT$
  980.     GetC = Asc(BT$)
  981. End Function
  982.  
  983. Function GetInt& ()
  984.     Dim C&, N&
  985.     C = GetC()
  986.     If IntMot Then N = C Else N = C * 256
  987.     C = GetC()
  988.     If IntMot Then N = N + C * 256 Else N = N + C
  989.     GetInt = N
  990. End Function
  991.  
  992. Function GetLng& ()
  993.     Dim C&, N&
  994.     C = GetC()
  995.     If IntMot Then N = C Else N = C * 16777216
  996.     C = GetC()
  997.     If IntMot Then N = N + C * 256 Else N = N + C * 65536
  998.     C = GetC()
  999.     If IntMot Then N = N + C * 65536 Else N = N + C * 256
  1000.     C = GetC()
  1001.     If IntMot Then N = N + C * 16777216 Else N = N + C
  1002.     GetLng = N
  1003. End Function
  1004.  
  1005. Sub HScroll1_Change ()
  1006.     PX = -Hscroll1.Value
  1007.     Pic_Graphic.Move PX, PY
  1008. End Sub
  1009.  
  1010. Sub Info_ART ()
  1011.     Dim C&
  1012.      
  1013.     IntMot = True
  1014.     Fi = FreeFile
  1015.     Open File$ For Binary As Fi
  1016.     C = GetInt()
  1017.     C = GetInt()
  1018.     Lst_Info.AddItem "Image Width" & Chr$(9) & ": " & Format$(C)
  1019.     C = GetInt()
  1020.     C = GetInt()
  1021.     Lst_Info.AddItem "Image Height" & Chr$(9) & ": " & Format$(C)
  1022.     Lst_Info.AddItem "Bits per Pixel" & Chr$(9) & ": 1 "
  1023.     Close
  1024. End Sub
  1025.  
  1026. Sub Info_BMP ()
  1027.     Dim BH    As BMPHEAD
  1028.     Dim BMP   As BITMAPINFOHEADER
  1029.     
  1030.     Fi = FreeFile
  1031.     Open File$ For Binary As Fi
  1032.     Get #Fi, , BH
  1033.     Get #Fi, , BMP
  1034.     Close
  1035.     Lst_Info.AddItem "ID" & Chr$(9) & ": " & Format$(BH.ID)
  1036.     Lst_Info.AddItem "File Size" & Chr$(9) & ": " & Format$(BH.FileSize)
  1037.     Lst_Info.AddItem "Reserved(0)" & Chr$(9) & ": " & Format$(BH.Reserved(0))
  1038.     Lst_Info.AddItem "Reserved(1)" & Chr$(9) & ": " & Format$(BH.Reserved(1))
  1039.     Lst_Info.AddItem "Header Size" & Chr$(9) & ": " & Format$(BH.HeaderSize)
  1040.     Lst_Info.AddItem "Info Size" & Chr$(9) & ": " & Format$(BMP.biSize)
  1041.     Lst_Info.AddItem "Width" & Chr$(9) & ": " & Format$(BMP.biWidth)
  1042.     Lst_Info.AddItem "Depth" & Chr$(9) & ": " & Format$(BMP.biHeight)
  1043.     Lst_Info.AddItem "BiPlanes" & Chr$(9) & ": " & Format$(BMP.biPlanes)
  1044.     Lst_Info.AddItem "Bits" & Chr$(9) & ": " & Format$(BMP.biBitCount)
  1045.     If BMP.biSize <> 12 Then
  1046.     Lst_Info.AddItem "BiCompression" & Chr$(9) & ": " & Format$(BMP.biCompression)
  1047.     Lst_Info.AddItem "BiSizeImage" & Chr$(9) & ": " & Format$(BMP.biSizeImage)
  1048.     Lst_Info.AddItem "BiPiXPelsPerMeter" & Chr$(9) & ": " & Format$(BMP.biXPelsPerMeter)
  1049.     Lst_Info.AddItem "BiPiYPelsPerMeter" & Chr$(9) & ": " & Format$(BMP.biYPelsPerMeter)
  1050.     Lst_Info.AddItem "BiClrUsed" & Chr$(9) & ": " & Format$(BMP.biClrUsed)
  1051.     Lst_Info.AddItem "BiClrImportant" & Chr$(9) & ": " & Format$(BMP.biClrImportant)
  1052.     Else
  1053.     Lst_Info.AddItem "Bitmap from OS/2"
  1054.     End If
  1055. End Sub
  1056.  
  1057. Sub Info_CUT ()
  1058.     Dim CUT As CUTHEAD
  1059.     Dim Pal$
  1060.  
  1061.     Fi = FreeFile
  1062.     Open File$ For Binary As Fi
  1063.     Get #Fi, , CUT
  1064.     Close
  1065.     Lst_Info.AddItem "Width" & Chr$(9) & ": " & Format$(CUT.Width)
  1066.     Lst_Info.AddItem "Height" & Chr$(9) & ": " & Format$(CUT.Height)
  1067.     Pal$ = Left$(File$, Len(File$) - 3) & "pal"
  1068.     If Dir$(Pal$) = "" Then Pal$ = "No Palette"
  1069.     Lst_Info.AddItem "Palette file" & Chr$(9) & ": " & Pal$
  1070. End Sub
  1071.  
  1072. Sub Info_GIF ()
  1073.     Dim GIF As GIFHEADER
  1074.     Dim Image As IMAGEBLOCK
  1075.     Dim A$, B$, I%, Clr%
  1076.     Dim Flag%, NumClrs%, NumClrBits%
  1077.  
  1078.     Fi = FreeFile
  1079.     Open File$ For Binary As Fi
  1080.     Get #Fi, , GIF
  1081.     Lst_Info.AddItem "Signature" & Chr$(9) & ": " & GIF.GIF
  1082.     Lst_Info.AddItem "Screen Width" & Chr$(9) & ": " & Format$(GIF.Width)
  1083.     Lst_Info.AddItem "Screen Height" & Chr$(9) & ": " & Format$(GIF.Height)
  1084.     Lst_Info.AddItem "Bits" & Chr$(9) & ": " & Format$((Asc(GIF.Flags) And &H7) + 1)
  1085.     Lst_Info.AddItem "Colors" & Chr$(9) & ": " & Format$(2 ^ ((Asc(GIF.Flags) And &H7) + 1))
  1086.     Lst_Info.AddItem "Background" & Chr$(9) & ": " & Format$(Asc(GIF.Background))
  1087.     Lst_Info.AddItem "Aspect" & Chr$(9) & ": " & Format$(Asc(GIF.Aspect))
  1088.     Flag = Asc(GIF.Flags)
  1089.     B$ = "No"
  1090.     If (Flag And &H80) Then
  1091.     NumClrBits = (Flag And &H7) + 1
  1092.     NumClrs = 2 ^ NumClrBits
  1093.     A$ = String$(NumClrs * 3, 0)
  1094.     Get #Fi, , A$
  1095.     B$ = "Yes"
  1096.     End If
  1097.     Lst_Info.AddItem "Global color map" & Chr$(9) & ": " & B$
  1098.     Do
  1099.     Get #Fi, , BT$
  1100.     Select Case BT$
  1101.     Case ","
  1102.         Lst_Info.AddItem "Image block"
  1103.         Get #Fi, , Image
  1104.         Lst_Info.AddItem "Image Width" & Chr$(9) & ": " & Format$(Image.Width)
  1105.         Lst_Info.AddItem "Image Height" & Chr$(9) & ": " & Format$(Image.Height)
  1106.         Flag = Asc(Image.Flags)
  1107.         B$ = "No"
  1108.         If (Flag And &H80) Then
  1109.         Lst_Info.AddItem "Image bits" & Chr$(9) & ": " & Format$((Flag And &H7) + 1)
  1110.         NumClrBits = (Flag And &H7) + 1
  1111.         NumClrs = 2 ^ NumClrBits
  1112.         A$ = String$(NumClrs * 3, 0)
  1113.         Get #Fi, , A$
  1114.         B$ = "Yes"
  1115.         End If
  1116.         Lst_Info.AddItem "Local color map" & Chr$(9) & ": " & B$
  1117.         B$ = "No"
  1118.         If (Flag And &H40) Then B$ = "Yes"
  1119.         Lst_Info.AddItem "Interlaced" & Chr$(9) & ": " & B$
  1120.         I = GetC()
  1121.         I = 1
  1122.         Do Until I = 0
  1123.         I = GetC()
  1124.         Seek #Fi, Seek(Fi) + I
  1125.         Loop
  1126.  
  1127.     Case "!"
  1128.         Get #Fi, , BT$
  1129.  
  1130.         Select Case Asc(BT$)          ' Plain Text Extension
  1131.         Case 1
  1132.         Dim PlnTxt As PLAINTEXT
  1133.         Lst_Info.AddItem "Plain text block"
  1134.         Get #Fi, , PlnTxt
  1135.         Clr = Asc(PlnTxt.ForeColor)
  1136.         Lst_Info.AddItem "Fore color" & Chr$(9) & ": " & Format$(Clr)
  1137.         Clr = Asc(PlnTxt.BackColor)
  1138.         Lst_Info.AddItem "Back color" & Chr$(9) & ": " & Format$(Clr)
  1139.         Lst_Info.AddItem "Text location (top)" & Chr$(9) & ": " & Format$(PlnTxt.Top)
  1140.         Lst_Info.AddItem "Text location (left)" & Chr$(9) & ": " & Format$(PlnTxt.Left)
  1141.         Lst_Info.AddItem "Grid width" & Chr$(9) & ": " & Format$(PlnTxt.GridWidth)
  1142.         Lst_Info.AddItem "Grid height" & Chr$(9) & ": " & Format$(PlnTxt.GridHeight)
  1143.         Lst_Info.AddItem "Cell width" & Chr$(9) & ": " & Format$(PlnTxt.CellWidth)
  1144.         Lst_Info.AddItem "Cell height" & Chr$(9) & ": " & Format$(PlnTxt.CellHeight)
  1145.         A$ = ""
  1146.         Do
  1147.         For I = 1 To GetC()
  1148.         Get #Fi, , BT$
  1149.         If BT$ = Chr$(0) Or EOF(Fi) Then Exit Do
  1150.         A$ = A$ + B$
  1151.         Next I
  1152.         Loop
  1153.         Lst_Info.AddItem "Text" & Chr$(9) & ": " & B$
  1154.  
  1155.         Case 249                      'Control Block Extension
  1156.         Dim Cntrlblk As CONTROLBLOCK
  1157.         Get #Fi, , Cntrlblk
  1158.         Flag = Asc(Cntrlblk.Flags)
  1159.         Select Case (Flag * 4) And &H7
  1160.         Case 0
  1161.             A$ = "No disposal specified"
  1162.  
  1163.         Case 1
  1164.             A$ = "Do not dispose"
  1165.  
  1166.         Case 2
  1167.             A$ = "Dispose to background color"
  1168.  
  1169.         Case 3
  1170.             A$ = "Dispose to previous graphic"
  1171.  
  1172.         Case Else
  1173.             A$ = "Unknown disposal procedure"
  1174.         
  1175.         End Select
  1176.         
  1177.         Lst_Info.AddItem "Control block" & Chr$(9) & ": " & A$
  1178.         
  1179.         If Flag And 2 Then
  1180.             Lst_Info.AddItem "User input required, delay for" & Chr$(9) & ": " & Format$(Cntrlblk.Delay) & " seconds"
  1181.         End If
  1182.  
  1183.         If Flag And 1 Then
  1184.             Lst_Info.AddItem "Transparent color" & Chr$(9) & ": " & Format$(Asc(Cntrlblk.Transparent_Color))
  1185.         Else
  1186.             Lst_Info.AddItem "No transparent color"
  1187.         End If
  1188.         
  1189.         Case 254                      'Comment Extension
  1190.         A$ = ""
  1191.         Do
  1192.         For I = 1 To GetC()
  1193.         Get #Fi, , BT$
  1194.         If BT$ = Chr$(0) Or EOF(Fi) Then Exit Do
  1195.         A$ = A$ & BT$
  1196.         Next I
  1197.         Loop
  1198.         Lst_Info.AddItem "Comment extension" & Chr$(9) & ": " & Format$(Len(A$)) & " characters"
  1199.          
  1200.         Case 255                      'Application Extension
  1201.         Dim Appl As Application
  1202.         Get #Fi, , Appl
  1203.         Lst_Info.AddItem "Application identification string" & Chr$(9) & ": " & Appl.Applstring
  1204.         Lst_Info.AddItem "Application authorization string" & Chr$(9) & ": " & Appl.Authentication
  1205.         Do
  1206.         For I = 1 To GetC()
  1207.         Get #Fi, , BT$
  1208.         If BT$ = Chr$(0) Or EOF(Fi) Then Exit Do
  1209.         Next I
  1210.         Loop
  1211.  
  1212.         Case Else
  1213.         Lst_Info.AddItem "Unknown control block"
  1214.         Do
  1215.         For I = 1 To GetC()
  1216.         Get #Fi, , BT$
  1217.         If BT$ = Chr$(0) Or EOF(Fi) Then Exit Do
  1218.         Next I
  1219.         Loop
  1220.         
  1221.         End Select
  1222.  
  1223.     Case Chr$(0)
  1224.         If EOF(Fi) Then Exit Do
  1225.     
  1226.     Case Else
  1227.         Exit Do
  1228.  
  1229.     End Select
  1230.     Loop
  1231.     Close
  1232. End Sub
  1233.  
  1234. Sub Info_HRZ ()
  1235.     If FileLen(File$) <> 184320 Then
  1236.     MsgBox "Not a HRZ file", 48, "Graphics Viewer"
  1237.     End If
  1238.     Lst_Info.AddItem "Image Width" & Chr$(9) & ": 256"
  1239.     Lst_Info.AddItem "Image Height" & Chr$(9) & ": 240"
  1240.     Lst_Info.AddItem "Bits per Pixel" & Chr$(9) & ": 24"
  1241. End Sub
  1242.  
  1243. Sub Info_IFF ()
  1244.     Dim IFF As IFFHEAD, BMHEAD As BMHD
  1245.     Dim B$, Lng As String * 4
  1246.     Dim Chnk As String * 4, Pos&, Size&
  1247.     
  1248.     Fi = FreeFile
  1249.     Open File$ For Binary As Fi
  1250.     Get #Fi, , IFF
  1251.     Lst_Info.AddItem "Type" & Chr$(9) & ": " & IFF.Ftype
  1252.     Lst_Info.AddItem "Size" & Chr$(9) & ": " & Format$(CnvtLng(IFF.Size))
  1253.     Lst_Info.AddItem "SubType" & Chr$(9) & ": " & IFF.SubType
  1254.     Do
  1255.     Get #Fi, , Chnk$
  1256.     Get #Fi, , Lng$
  1257.     Pos = Seek(Fi)
  1258.     Size = CnvtLng(Lng$)
  1259.     If Size And 1 Then Size = Size + 1
  1260.     Select Case Chnk$
  1261.     Case "BMHD"
  1262.     Get #Fi, , BMHEAD
  1263.     Lst_Info.AddItem "Width" & Chr$(9) & ": " & Format$(CnvtInt(BMHEAD.W))
  1264.     Lst_Info.AddItem "Height" & Chr$(9) & ": " & Format$(CnvtInt(BMHEAD.H))
  1265.     Lst_Info.AddItem "Top" & Chr$(9) & ": " & Format$(CnvtInt(BMHEAD.Y))
  1266.     Lst_Info.AddItem "Left" & Chr$(9) & ": " & Format$(CnvtInt(BMHEAD.X))
  1267.     Lst_Info.AddItem "Color planes" & Chr$(9) & ": " & Format$(Asc(BMHEAD.nplanes))
  1268.     B$ = "Unknown"
  1269.     If BMHEAD.Masking = Chr$(0) Then B$ = "No mask present"
  1270.     If BMHEAD.Masking = Chr$(1) Then B$ = "Mask present"
  1271.     If BMHEAD.Masking = Chr$(2) Then B$ = "Mask w/transparent color"
  1272.     If BMHEAD.Masking = Chr$(3) Then B$ = "Lasso mask"
  1273.     Lst_Info.AddItem "Masking" & Chr$(9) & ": " & B$
  1274.     B$ = "Uncompressed"
  1275.     If BMHEAD.Compression = Chr$(1) Then B$ = "Compressed"
  1276.     Lst_Info.AddItem "Compression" & Chr$(9) & ": " & B$
  1277.     Lst_Info.AddItem "X Aspect" & Chr$(9) & ": " & Format$(Asc(BMHEAD.XAspect))
  1278.     Lst_Info.AddItem "Page Width" & Chr$(9) & ": " & Format$(CnvtInt(BMHEAD.PageW))
  1279.     Lst_Info.AddItem "Page Height" & Chr$(9) & ": " & Format$(CnvtInt(BMHEAD.PageH))
  1280.     
  1281.     Case "CMAP"
  1282.     Lst_Info.AddItem "Color map size" & Chr$(9) & ": " & Format$(Size)
  1283.  
  1284.     Case "TEXT"
  1285.     If Size <= 40 Then
  1286.         B$ = Space$(Size)
  1287.         Get #Fi, , B$
  1288.         Lst_Info.AddItem "Text" & Chr$(9) & ": " & B$
  1289.     Else
  1290.         Lst_Info.AddItem "Chunk Name" & Chr$(9) & ": " & Chnk$
  1291.         Lst_Info.AddItem "Chunk Size" & Chr$(9) & ": " & Format$(Size)
  1292.     End If
  1293.     
  1294.     Case Else
  1295.     Lst_Info.AddItem "Chunk Name" & Chr$(9) & ": " & Chnk$
  1296.     Lst_Info.AddItem "Chunk Size" & Chr$(9) & ": " & Format$(Size)
  1297.     
  1298.     End Select
  1299.     Seek #Fi, Pos + Size
  1300.     Loop Until Chnk$ = "BODY" Or EOF(Fi)
  1301.     Close
  1302. End Sub
  1303.  
  1304. Sub Info_IMG ()
  1305.     Dim A$, I&, H&, N&
  1306.  
  1307.     IntMot = False
  1308.     Fi = FreeFile
  1309.     Open File$ For Binary As Fi
  1310.     I = GetInt()
  1311.     Lst_Info.AddItem "Version" & Chr$(9) & ": " & Hex$(I)
  1312.     H = GetInt()
  1313.     Lst_Info.AddItem "Header Length" & Chr$(9) & ": " & Format$(H)
  1314.     N = GetInt()
  1315.     Lst_Info.AddItem "Number of Planes" & Chr$(9) & ": " & Format$(N)
  1316.     I = GetInt()
  1317.     Lst_Info.AddItem "Pattern Length" & Chr$(9) & ": " & Format$(I)
  1318.     I = GetInt()
  1319.     Lst_Info.AddItem "Pixel Width" & Chr$(9) & ": " & Format$(I)
  1320.     I = GetInt()
  1321.     Lst_Info.AddItem "Pixel Height" & Chr$(9) & ": " & Format$(I)
  1322.     I = GetInt()
  1323.     Lst_Info.AddItem "Image Width" & Chr$(9) & ": " & Format$(I)
  1324.     I = GetInt()
  1325.     Lst_Info.AddItem "Image Height" & Chr$(9) & ": " & Format$(I)
  1326.     A$ = "True Color"
  1327.     If H = 9 And N >= 2 Then
  1328.     I = GetInt()
  1329.     If I = 0 Then A$ = "Color Image Data"
  1330.     If I = 1 Then A$ = "Gray-scale Image Data"
  1331.     End If
  1332.     If H = 8 Then A$ = "16 color Gray-Scale"
  1333.     Lst_Info.AddItem "Image" & Chr$(9) & ": " & A$
  1334.     Close
  1335. End Sub
  1336.  
  1337. Sub Info_JPG ()
  1338.     Dim Marker, T
  1339.     
  1340.     IntMot = False
  1341.     Fi = FreeFile
  1342.     Open File$ For Binary As Fi
  1343.     
  1344.     If First_Marker() <> M_SOI Then
  1345.     MsgBox "Expected SOI marker first", 48, "Graphics Viewer"
  1346.     Close Fi
  1347.     Exit Sub
  1348.     End If
  1349.     Do
  1350.     Marker = Next_Marker()
  1351.     Select Case Marker
  1352.     Case -1
  1353.         MsgBox "Error ocurred", 48, "JPEG Reader"
  1354.         Exit Sub
  1355.         
  1356.     Case M_SOF0, M_SOF1, M_SOF2, M_SOF3, M_SOF5, M_SOF6, M_SOF7, M_SOF9, M_SOF10, M_SOF11, M_SOF13, M_SOF14, M_SOF15
  1357.         Process_SOFn Marker
  1358.     
  1359.     Case M_SOS
  1360.         Lst_Info.AddItem "Start of scan"
  1361.         Exit Sub
  1362.     
  1363.     Case M_SOI
  1364.         Lst_Info.AddItem "Start of image"
  1365.         Exit Sub
  1366.     
  1367.     Case M_EOI
  1368.         Lst_Info.AddItem "End of image"
  1369.         Exit Sub
  1370.     
  1371.     Case M_COM
  1372.         Process_COM
  1373.         If Canc Then Exit Sub
  1374.     
  1375.     Case Else
  1376.         Skip_Variable
  1377.     
  1378.     End Select
  1379.     
  1380.     Loop
  1381.     Close
  1382. End Sub
  1383.  
  1384. Sub Info_MAC ()
  1385.     Dim MAC As MACHEAD
  1386.     Dim Dt#
  1387.  
  1388.     Fi = FreeFile
  1389.     Open File$ For Binary As Fi
  1390.     Get #Fi, , MAC
  1391.     Close
  1392.     Lst_Info.AddItem "Name" & Chr$(9) & ": " & MAC.Name
  1393.     Lst_Info.AddItem "Type" & Chr$(9) & ": " & MAC.Type
  1394.     Lst_Info.AddItem "Creator" & Chr$(9) & ": " & MAC.Creator
  1395.     Lst_Info.AddItem "Data fork size" & Chr$(9) & ": " & Format$(CnvtLng(MAC.DataFork_Size))
  1396.     Lst_Info.AddItem "Resource fork size" & Chr$(9) & ": " & Format$(CnvtLng(MAC.RsrcFork_Size))
  1397.     Dt = CnvtLng(MAC.Creation_Date) / 86400 + 1462
  1398.     Lst_Info.AddItem "Creation date" & Chr$(9) & ": " & CVDate(Dt)
  1399.     Dt = CnvtLng(MAC.Modif_Date) / 86400 + 1462
  1400.     Lst_Info.AddItem "Modification date" & Chr$(9) & ": " & CVDate(Dt)
  1401.     Lst_Info.AddItem "Width" & Chr$(9) & ": 576"
  1402.     Lst_Info.AddItem "Height" & Chr$(9) & ": 720"
  1403. End Sub
  1404.  
  1405. Sub Info_MSP ()
  1406.     Dim MSP As MSPHEAD
  1407.     Dim A$
  1408.  
  1409.     Fi = FreeFile
  1410.     Open File$ For Binary As Fi
  1411.     Get #Fi, , MSP
  1412.     Close
  1413.     A$ = "Unknown"
  1414.     If MSP.Key1 = 24900 And MSP.Key2 = 19822 Then A$ = "1.0"
  1415.     If MSP.Key1 = 26956 And MSP.Key2 = 21358 Then A$ = "2.0"
  1416.     Lst_Info.AddItem "Windows Version" & Chr$(9) & ": " & A$
  1417.     Lst_Info.AddItem "Width" & Chr$(9) & ": " & Format$(MSP.Width)
  1418.     Lst_Info.AddItem "Height" & Chr$(9) & ": " & Format$(MSP.Height)
  1419.     Lst_Info.AddItem "Screen Aspect X" & Chr$(9) & ": " & Format$(MSP.ScrAspX)
  1420.     Lst_Info.AddItem "Screen Aspect Y" & Chr$(9) & ": " & Format$(MSP.ScrAspY)
  1421.     Lst_Info.AddItem "Printer Aspect X" & Chr$(9) & ": " & Format$(MSP.PrnAspX)
  1422.     Lst_Info.AddItem "Printer Aspect Y" & Chr$(9) & ": " & Format$(MSP.PrnAspY)
  1423. End Sub
  1424.  
  1425. Sub Info_PCX ()
  1426.     Dim PCX As PCXHEAD
  1427.     Dim A$
  1428.  
  1429.     Fi = FreeFile
  1430.     Open File$ For Binary As Fi
  1431.     Get #Fi, , PCX
  1432.     Close
  1433.     A$ = "Unknown"
  1434.     If PCX.Version = Chr$(0) Then A$ = "2.5"
  1435.     If PCX.Version = Chr$(2) Then A$ = "2.8 Palette included"
  1436.     If PCX.Version = Chr$(3) Then A$ = "2.8 Use default palette"
  1437.     If PCX.Version = Chr$(5) Then A$ = "3.0 (or later)"
  1438.     Lst_Info.AddItem "Manufacturer" & Chr$(9) & ": " & Format$(Asc(PCX.Manufacturer))
  1439.     Lst_Info.AddItem "PC Paintbrush Ver." & Chr$(9) & ": " & A$
  1440.     Lst_Info.AddItem "Encoding" & Chr$(9) & ": " & Format$(Asc(PCX.Encoding))
  1441.     Lst_Info.AddItem "Bits per pixel" & Chr$(9) & ": " & Format$(Asc(PCX.Bits_Per_Pixel))
  1442.     Lst_Info.AddItem "Width" & Chr$(9) & ": " & Format$(PCX.XMax - PCX.XMin + 1)
  1443.     Lst_Info.AddItem "Height" & Chr$(9) & ": " & Format$(PCX.YMax - PCX.YMin + 1)
  1444.     Lst_Info.AddItem "Horiz. Resolution" & Chr$(9) & ": " & Format$(PCX.HRes)
  1445.     Lst_Info.AddItem "Vert. Resolution" & Chr$(9) & ": " & Format$(PCX.VRes)
  1446.     Lst_Info.AddItem "Color planes" & Chr$(9) & ": " & Format$(Asc(PCX.Color_Planes))
  1447.     Lst_Info.AddItem "Bytes per line" & Chr$(9) & ": " & Format$(PCX.Bytes_Per_Line)
  1448.     If PCX.Palette_Type = 1 Then A$ = "Gray scale" Else A$ = "Color"
  1449.     Lst_Info.AddItem "Palette type" & Chr$(9) & ": " & A$
  1450. End Sub
  1451.  
  1452. Sub Info_PIC ()
  1453.     Dim PIC As PICHEAD
  1454.     Dim A$, Bits%, PLANES%
  1455.  
  1456.     Fi = FreeFile
  1457.     Open File$ For Binary As Fi
  1458.     Get #Fi, , PIC
  1459.     Close
  1460.     Lst_Info.AddItem "Mark" & Chr$(9) & ": " & Hex$(PIC.Mark)
  1461.     Lst_Info.AddItem "Width" & Chr$(9) & ": " & Format$(PIC.XSize)
  1462.     Lst_Info.AddItem "Height" & Chr$(9) & ": " & Format$(PIC.YSize)
  1463.     Lst_Info.AddItem "Top" & Chr$(9) & ": " & Format$(PIC.YOff)
  1464.     Lst_Info.AddItem "Left" & Chr$(9) & ": " & Format$(PIC.XOff)
  1465.     Bits = Asc(PIC.BitsInf)
  1466.     PLANES = Fix((Bits And &HF0) / 16) + 1
  1467.     Bits = (PLANES) * (Bits And &HF)
  1468.     Lst_Info.AddItem "Bits per pixel" & Chr$(9) & ": " & Format$(Bits)
  1469.     Lst_Info.AddItem "Color planes" & Chr$(9) & ": " & Format$(PLANES)
  1470.     Lst_Info.AddItem "EMark" & Chr$(9) & ": " & Format$(Asc(PIC.EMark))
  1471.     A$ = "Unknown"
  1472.     Select Case PIC.EVideo
  1473.     Case "A"
  1474.     A$ = "CGA 4 color"
  1475.  
  1476.     Case "B"
  1477.     A$ = "PCjr/Tandy 1000"
  1478.  
  1479.     Case "C"
  1480.     A$ = "CGA 2 color"
  1481.  
  1482.     Case "D"
  1483.     A$ = "EGA low resolution"
  1484.  
  1485.     Case "E"
  1486.     A$ = "EGA 2 color"
  1487.  
  1488.     Case "F"
  1489.     A$ = "EGA 4 color"
  1490.  
  1491.     Case "G"
  1492.     A$ = "EGA 16 color"
  1493.  
  1494.     Case "H"
  1495.     A$ = "Hercules monochrome"
  1496.  
  1497.     Case "I"
  1498.     A$ = "Plantronic"
  1499.  
  1500.     Case "J"
  1501.     A$ = "EGA low resolution"
  1502.  
  1503.     Case "K"
  1504.     A$ = "AT&T or Toshiba 3100"
  1505.  
  1506.     Case "L"
  1507.     A$ = "VGA 256 color"
  1508.  
  1509.     Case "M"
  1510.     A$ = "VGA 16 color"
  1511.  
  1512.     Case "N"
  1513.     A$ = "Hercules InColor"
  1514.  
  1515.     Case "O"
  1516.     A$ = "VGA monochrome"
  1517.  
  1518.     End Select
  1519.     Lst_Info.AddItem "Video" & Chr$(9) & ": " & A$
  1520.     A$ = "Unknown"
  1521.     Select Case PIC.EDesc
  1522.     Case 0
  1523.     A$ = "No palette"
  1524.  
  1525.     Case 1
  1526.     A$ = "One byte of color for a CGA border"
  1527.  
  1528.     Case 2
  1529.     A$ = "PCjr palette"
  1530.  
  1531.     Case 3
  1532.     A$ = "EGA palette"
  1533.  
  1534.     Case 4
  1535.     A$ = "VGA palette"
  1536.     End Select
  1537.     Lst_Info.AddItem "Palette" & Chr$(9) & ": " & A$
  1538.     Lst_Info.AddItem "Palette size" & Chr$(9) & ": " & Format$(PIC.ESize)
  1539. End Sub
  1540.  
  1541. Sub Info_RAS ()
  1542.     Dim A$, I&
  1543.  
  1544.     IntMot = False
  1545.     Fi = FreeFile
  1546.     Open File$ For Binary As Fi
  1547.     I = GetLng()
  1548.     Lst_Info.AddItem "Magic Number" & Chr$(9) & ": " & Hex$(I)
  1549.     I = GetLng()
  1550.     Lst_Info.AddItem "Image Width" & Chr$(9) & ": " & Format$(I)
  1551.     I = GetLng()
  1552.     Lst_Info.AddItem "Image Height" & Chr$(9) & ": " & Format$(I)
  1553.     I = GetLng()
  1554.     Lst_Info.AddItem "Bits per Pixel" & Chr$(9) & ": " & Format$(I)
  1555.     I = GetLng()
  1556.     Lst_Info.AddItem "Image Size" & Chr$(9) & ": " & Format$(I)
  1557.     I = GetLng()
  1558.  
  1559.     Select Case I
  1560.     Case 0
  1561.     A$ = "Old    "
  1562.     Case 1
  1563.     A$ = "Standard"
  1564.     Case 2
  1565.     A$ = "Byte-encoded"
  1566.     Case 3
  1567.     A$ = "RGB format"
  1568.     Case 4
  1569.     A$ = "TIFF format"
  1570.     Case 5
  1571.     A$ = "IFF format"
  1572.     Case &HFFFF
  1573.     A$ = "Experimental"
  1574.     End Select
  1575.  
  1576.     Lst_Info.AddItem "Type" & Chr$(9) & ": " & A$
  1577.     I = GetLng()
  1578.  
  1579.     Select Case I
  1580.     Case 0
  1581.     A$ = "No color map"
  1582.     Case 1
  1583.     A$ = "RGB color map"
  1584.     Case 2
  1585.     A$ = "Raw color map"
  1586.     End Select
  1587.  
  1588.     Lst_Info.AddItem "Color Map Type" & Chr$(9) & ": " & A$
  1589.     I = GetLng()
  1590.     Lst_Info.AddItem "Color Map Length" & Chr$(9) & ": " & Format$(I)
  1591.     Close
  1592. End Sub
  1593.  
  1594. Sub Info_TGA ()
  1595.     Dim TGA As TGAHEAD
  1596.     Dim A$
  1597.  
  1598.     Fi = FreeFile
  1599.     Open File$ For Binary As Fi
  1600.     Get #Fi, , TGA
  1601.     Close
  1602.     Lst_Info.AddItem "IdentSize" & Chr$(9) & ": " & Format$(Asc(TGA.IdentSize))
  1603.     A$ = "None"
  1604.     If TGA.ColorMapType <> Chr$(0) Then A$ = "Present"
  1605.     Lst_Info.AddItem "Color Map" & Chr$(9) & ": " & A$
  1606.     A$ = "Unknown"
  1607.     Select Case Asc(TGA.ImageType)
  1608.     Case 1
  1609.     A$ = "Uncompressed palette-driven"
  1610.  
  1611.     Case 2
  1612.     A$ = "Uncompressed RGB"
  1613.  
  1614.     Case 3
  1615.     A$ = "Uncompressed monochrome"
  1616.  
  1617.     Case 9
  1618.     A$ = "Run-length encoded palette-driven"
  1619.  
  1620.     Case 10
  1621.     A$ = "Run-length encoded RGB"
  1622.  
  1623.     Case 11
  1624.     A$ = "Run-length encoded monochrome"
  1625.  
  1626.     End Select
  1627.  
  1628.     Lst_Info.AddItem "Image Type" & Chr$(9) & ": " & A$
  1629.     Lst_Info.AddItem "ColorMapStart" & Chr$(9) & ": " & Format$(TGA.ColorMapStart)
  1630.     Lst_Info.AddItem "ColorMapLength" & Chr$(9) & ": " & Format$(TGA.ColorMapLength)
  1631.     Lst_Info.AddItem "ColorMapBits" & Chr$(9) & ": " & Format$(Asc(TGA.ColorMapBits))
  1632.     Lst_Info.AddItem "X Start" & Chr$(9) & ": " & Format$(TGA.XStart)
  1633.     Lst_Info.AddItem "Y Start" & Chr$(9) & ": " & Format$(TGA.YStart)
  1634.     Lst_Info.AddItem "Width" & Chr$(9) & ": " & Format$(TGA.Width)
  1635.     Lst_Info.AddItem "Height" & Chr$(9) & ": " & Format$(TGA.Height)
  1636.     Lst_Info.AddItem "Color Bits" & Chr$(9) & ": " & Format$(Asc(TGA.Bits))
  1637.     A$ = "Normal storage"
  1638.     If Asc(TGA.Descriptor) And &H20 Then A$ = "Last line first"
  1639.     Lst_Info.AddItem "Storage" & Chr$(9) & ": " & A$
  1640.     A$ = "Normal storage"
  1641.     If Asc(TGA.Descriptor) And &H10 Then A$ = "Reversed"
  1642.     Lst_Info.AddItem "Storage" & Chr$(9) & ": " & A$
  1643. End Sub
  1644.  
  1645. Sub Info_TIF ()
  1646.     Dim A$, I%
  1647.     Dim Offset&, Tag&, Typ&, Length&, NumTags%
  1648.  
  1649.     Fi = FreeFile
  1650.     Open File$ For Binary As Fi
  1651.     A$ = Space$(2)
  1652.     Get #Fi, , A$
  1653.     If A$ = "II" Then IntMot = True Else IntMot = False
  1654.     If IntMot Then A$ = "Intel" Else A$ = "Motorola"
  1655.     Lst_Info.AddItem "Number Type" & Chr$(9) & ": " & A$
  1656.     A$ = Space$(2)
  1657.     Get #Fi, , A$
  1658.     If IntMot Then A$ = Left$(A$, 1) Else A$ = Right$(A$, 1)
  1659.     Offset = GetLng()
  1660.     Lst_Info.AddItem "Version" & Chr$(9) & ": " & Format$(Asc(A$))
  1661.     Lst_Info.AddItem "Offset" & Chr$(9) & ": " & Format$(Offset)
  1662.     Seek #Fi, Offset + 1
  1663.     NumTags = GetInt()
  1664.     ReDim TagsInfo(NumTags) As TIFFTAG
  1665.     Lst_Info.AddItem "Number" & Chr$(9) & ": " & Format$(NumTags)
  1666.     For I = 1 To NumTags
  1667.     Tag = GetInt()
  1668.     Typ = GetInt()
  1669.     Length = GetLng()
  1670.     Offset = GetLng()
  1671.     TagsInfo(I).Tag = Tag
  1672.     TagsInfo(I).Type = Typ
  1673.     TagsInfo(I).Length = Length
  1674.     TagsInfo(I).Offset = Offset
  1675.     Next I
  1676.     For I = 1 To NumTags
  1677.     If TagsInfo(I).Tag <= 532 Then Lst_Info.AddItem "Tag" & Chr$(9) & ": " & Tags(TagsInfo(I).Tag)
  1678.     A$ = ""
  1679.     Select Case TagsInfo(I).Type
  1680.     Case 1
  1681.     If TagsInfo(I).Length <= 1 Then
  1682.         A$ = Format$(TagsInfo(I).Offset And &HF)
  1683.     Else
  1684.         A$ = "Offset = " & Format$(TagsInfo(I).Offset) & "  Length = " & Format$(TagsInfo(I).Length)
  1685.     End If
  1686.     Case 2
  1687.     Seek #Fi, TagsInfo(I).Offset + 1
  1688.     Do
  1689.     Get #Fi, , BT$
  1690.     If BT$ <> "" Then A$ = A$ & BT$
  1691.     Loop Until Asc(BT$) = 0
  1692.     Case 3
  1693.     If TagsInfo(I).Length <= 1 Then
  1694.         A$ = Format$(TagsInfo(I).Offset And &HFFF)
  1695.     Else
  1696.         A$ = "Offset = " & Format$(TagsInfo(I).Offset) & "  Length = " & Format$(TagsInfo(I).Length)
  1697.     End If
  1698.     Case 4
  1699.     If TagsInfo(I).Length <= 1 Then
  1700.         A$ = Format$(TagsInfo(I).Offset)
  1701.     Else
  1702.         A$ = "Offset = " & Format$(TagsInfo(I).Offset) & "  Length = " & Format$(TagsInfo(I).Length)
  1703.     End If
  1704.     Case 5
  1705.     Seek #Fi, TagsInfo(I).Offset + 1
  1706.     A$ = Str$(GetLng() / GetLng())
  1707.     End Select
  1708.     Lst_Info.AddItem "Type" & Chr$(9) & ": " & Typs(TagsInfo(I).Type - 1) & " = " & A$
  1709.     Next I
  1710.     Close
  1711. End Sub
  1712.  
  1713. Sub Info_WMF ()
  1714.     Dim WMFH As METAFILEHEADER
  1715.     Dim WMF As METAHEADER
  1716.     Dim A$
  1717.  
  1718.     Fi = FreeFile
  1719.     Open File$ For Binary As Fi
  1720.     Get #Fi, , WMFH
  1721.     If WMFH.key <> &H9AC6CDD7 Then Seek #Fi, 1
  1722.     Get #Fi, , WMF
  1723.     Close
  1724.     If WMFH.key = &H9AC6CDD7 Then
  1725.     Lst_Info.AddItem "File header found"
  1726.     Lst_Info.AddItem "Left" & Chr$(9) & ": " & Format$(WMFH.bbox.Left)
  1727.     Lst_Info.AddItem "Top" & Chr$(9) & ": " & Format$(WMFH.bbox.Top)
  1728.     Lst_Info.AddItem "Right" & Chr$(9) & ": " & Format$(WMFH.bbox.right)
  1729.     Lst_Info.AddItem "Bottom" & Chr$(9) & ": " & Format$(WMFH.bbox.Bottom)
  1730.     Lst_Info.AddItem "Units per inch" & Chr$(9) & ": " & Format$(WMFH.inch)
  1731.     End If
  1732.     A$ = "Unknown"
  1733.     If WMF.mtType = 1 Then A$ = "Memory metafile"
  1734.     If WMF.mtType = 2 Then A$ = "Disk metafile"
  1735.     Lst_Info.AddItem "Type" & Chr$(9) & ": " & A$
  1736.     Lst_Info.AddItem "Header size" & Chr$(9) & ": " & Format$(WMF.mtHeaderSize)
  1737.     A$ = "Unknown"
  1738.     If WMF.mtVersion = &H300 Then A$ = "Supports DIB format"
  1739.     If WMF.mtVersion = &H100 Then A$ = "No DIB support"
  1740.     Lst_Info.AddItem "Version" & Chr$(9) & ": " & A$
  1741.     Lst_Info.AddItem "Size" & Chr$(9) & ": " & Format$(WMF.mtSize)
  1742.     Lst_Info.AddItem "Number of objects" & Chr$(9) & ": " & Format$(WMF.mtNoObjects)
  1743.     Lst_Info.AddItem "Max record" & Chr$(9) & ": " & Format$(WMF.mtMaxRecord)
  1744.     Lst_Info.AddItem "Num. of parameters" & Chr$(9) & ": " & Format$(WMF.mtNoParameters)
  1745. End Sub
  1746.  
  1747. Sub Info_WPG ()
  1748.     Dim WPG As WPGHEAD
  1749.     Dim Typ, T&, I&, L&
  1750.  
  1751.     Fi = FreeFile
  1752.     IntMot = True
  1753.     Open File$ For Binary As Fi
  1754.     Get #Fi, , WPG
  1755.     Lst_Info.AddItem "ID" & Chr$(9) & ": " & Right$(WPG.ID, 3)
  1756.     Lst_Info.AddItem "First record offset" & Chr$(9) & ": " & Format$(WPG.Start)
  1757.     Lst_Info.AddItem "Product" & Chr$(9) & ": " & Format$(Asc(WPG.Product))
  1758.     Lst_Info.AddItem "File type" & Chr$(9) & ": " & Format$(Asc(WPG.FileType))
  1759.     Lst_Info.AddItem "Major Version" & Chr$(9) & ": " & Format$(Asc(WPG.MajorVersion))
  1760.     Lst_Info.AddItem "Minor Version" & Chr$(9) & ": " & Format$(Asc(WPG.MinorVersion))
  1761.     Lst_Info.AddItem "Encryption" & Chr$(9) & ": " & Format$(WPG.Encrypt)
  1762.     Lst_Info.AddItem "Reserved" & Chr$(9) & ": " & Format$(WPG.Reserved)
  1763.     Seek #Fi, WPG.Start + 1
  1764.     Do
  1765.     Typ = GetC()
  1766.     T = Seek(Fi)
  1767.     I = GetC()
  1768.     If I = 255 Then
  1769.         I = GetInt()
  1770.         If I And &H8000 Then
  1771.         L = (I And &H7FFF) * 2 ^ 16
  1772.         I = GetInt()
  1773.         L = L + I + 4
  1774.         Else
  1775.         L = I + 2
  1776.         End If
  1777.     Else
  1778.         L = I
  1779.     End If
  1780.     
  1781.     Select Case Typ
  1782.     Case 11
  1783.         Lst_Info.AddItem "Width" & Chr$(9) & ": " & Format$(GetInt())
  1784.         Lst_Info.AddItem "Height" & Chr$(9) & ": " & Format$(GetInt())
  1785.         Lst_Info.AddItem "Bits" & Chr$(9) & ": " & Format$(GetInt())
  1786.         Lst_Info.AddItem "Bitmap found"
  1787.         Found_BMP = True
  1788.     
  1789.     Case 14
  1790.         Lst_Info.AddItem "Color map found"
  1791.     
  1792.     End Select
  1793.     
  1794.     Seek #Fi, T + L + 1
  1795.     Loop While Seek(Fi) < LOF(Fi)
  1796.     Close
  1797.     If Found_BMP = False Then Lst_Info.AddItem "No Bitmap found"
  1798. End Sub
  1799.  
  1800. Sub Mnu_Close_Click ()
  1801.     Pic_Graphic.Visible = False
  1802.     Frame1.Visible = True
  1803.     Mnu_Close.Visible = False
  1804.     Ret = DoEvents()
  1805.     Hscroll1.Visible = False
  1806.     Vscroll1.Visible = False
  1807.     Picture2.Visible = False
  1808.     Ret = DoEvents()
  1809. End Sub
  1810.  
  1811. Function Next_Marker ()
  1812.     Dim C, Discarded_Bytes
  1813.     
  1814.     C = GetC()
  1815.     While C <> &HFF
  1816.     Discarded_Bytes = Discarded_Bytes + 1
  1817.     C = GetC()
  1818.     Wend
  1819.     Do
  1820.     C = GetC()
  1821.     Loop While C = &HFF
  1822.     If Discarded_Bytes <> 0 Then
  1823.     MsgBox "Garbage found in JPEG file", 48, "Graphics Viewer"
  1824.     Close Fi
  1825.     Next_Marker = -1
  1826.     Exit Function
  1827.     End If
  1828.     Next_Marker = C
  1829. End Function
  1830.  
  1831. Sub Picture2_Click ()
  1832.     Hscroll1.Value = Hscroll1.Max
  1833.     Vscroll1.Value = Vscroll1.Max
  1834. End Sub
  1835.  
  1836. Sub Picture2_DblClick ()
  1837.     Hscroll1.Value = 0
  1838.     Vscroll1.Value = 0
  1839. End Sub
  1840.  
  1841. Sub Process_COM ()
  1842.     Dim CH, Lastch, Length, A$
  1843.     
  1844.     Length = GetInt()
  1845.     If Length < 2 Then
  1846.     MsgBox "Errroneous JPEG marker length", 48, "Graphics Viewer"
  1847.     Close Fi
  1848.     Exit Sub
  1849.     End If
  1850.     Length = Length - 2
  1851.     While Length > 0
  1852.     CH = GetC()
  1853.     A$ = A$ & Chr$(CH)
  1854.     Length = Length - 1
  1855.     Wend
  1856.     MsgBox A$, 64, "JPEG Comment"
  1857. End Sub
  1858.  
  1859. Sub Process_SOFn (Marker)
  1860.     Dim Length, Image_Height, Image_Width, Data_Precision, Num_Components
  1861.     Dim Ci, C1, C2, C3
  1862.     Dim Process$
  1863.  
  1864.     Length = GetInt()
  1865.     Data_Precision = GetC()
  1866.     Image_Height = GetInt()
  1867.     Image_Width = GetInt()
  1868.     Num_Components = GetC()
  1869.     
  1870.     Select Case Marker
  1871.     Case M_SOF0
  1872.     Process = "Baseline"
  1873.     
  1874.     Case M_SOF1
  1875.     Process = "Extended sequential"
  1876.     
  1877.     Case M_SOF2
  1878.     Process = "Progressive"
  1879.     
  1880.     Case M_SOF3
  1881.     Process = "Lossless"
  1882.     
  1883.     Case M_SOF5
  1884.     Process = "Differential sequential"
  1885.     
  1886.     Case M_SOF6
  1887.     Process = "Differential progressive"
  1888.     
  1889.     Case M_SOF7
  1890.     Process = "Differential lossless"
  1891.     
  1892.     Case M_SOF9
  1893.     Process = "Extended sequential, arithmetic coding"
  1894.     
  1895.     Case M_SOF10
  1896.     Process = "Progressive, arithmetic coding"
  1897.     
  1898.     Case M_SOF11
  1899.     Process = "Lossless, arithmetic coding"
  1900.     
  1901.     Case M_SOF13
  1902.     Process = "Differential sequential, arithmetic coding"
  1903.     
  1904.     Case M_SOF14
  1905.     Process = "Differential progressive, arithmetic coding"
  1906.     
  1907.     Case M_SOF15
  1908.     Process = "Differential lossless, arithmetic coding"
  1909.     
  1910.     Case Else
  1911.     Process = "Unknown"
  1912.     
  1913.     End Select
  1914.     Lst_Info.AddItem "Process" & Chr$(9) & ": " & Process
  1915.     Lst_Info.AddItem "Width" & Chr$(9) & ": " & Format$(Image_Width)
  1916.     Lst_Info.AddItem "Height" & Chr$(9) & ": " & Format$(Image_Height)
  1917.     Lst_Info.AddItem "Color components" & Chr$(9) & ": " & Format$(Num_Components)
  1918.     Lst_Info.AddItem "Bits per sample" & Chr$(9) & ": " & Format$(Data_Precision)
  1919.     If Length <> 8 + Num_Components * 3 Then
  1920.     MsgBox "Bogus SOF marker length", 48, "Graphics Viewer"
  1921.     Close Fi
  1922.     Canc = True
  1923.     Exit Sub
  1924.     End If
  1925.     For Ci = 0 To Num_Components - 1
  1926.     C1 = GetC()
  1927.     C2 = GetC()
  1928.     C3 = GetC()
  1929.     Next Ci
  1930. End Sub
  1931.  
  1932. Sub Skip_Variable ()
  1933.     Dim Length, T
  1934.     
  1935.     Length = GetInt()
  1936.     If Length < 2 Then
  1937.     MsgBox "Errroneous JPEG marker length", 48, "Graphics Viewer"
  1938.     Close Fi
  1939.     Exit Sub
  1940.     End If
  1941.     Length = Length - 2
  1942.     Seek #Fi, Seek(Fi) + Length
  1943. End Sub
  1944.  
  1945. Sub VScroll1_Change ()
  1946.     PY = -Vscroll1.Value
  1947.     Pic_Graphic.Move PX, PY
  1948. End Sub
  1949.  
  1950.